package com.wyzz.hr.shift;

import java.math.BigDecimal;

import com.wyzz.hr.support.AttendDailyMemory;

public class DefaultFilter implements ExceptionDataFilter {

	public DefaultFilter() {
		zero = new BigDecimal(0);
	}

	public boolean doFilter(AttendDailyMemory memory, Integer searchType) {
		boolean flag = false;
		if (searchType == null || searchType.intValue() == 0)
			flag = true;
		else if (searchType.intValue() == 1) {
			if (memory != null && memory.getComments() != null
					&& !memory.getComments().trim().equals(""))
				flag = false;
			else
				flag = true;
		} else if (searchType.intValue() == 2) {
			if (memory != null && memory.getComments() != null
					&& !memory.getComments().trim().equals(""))
				flag = true;
		} else if (searchType.intValue() == 3) {
			if (memory != null && memory.getLateMinutes() != null
					&& memory.getLateMinutes().compareTo(zero) > 0)
				flag = true;
		} else if (searchType.intValue() == 4) {
			if (memory != null && memory.getEarlyMinutes() != null
					&& memory.getEarlyMinutes().compareTo(zero) > 0)
				flag = true;
		} else if (searchType.intValue() == 5) {
			if (memory != null && memory.getAbsentHours() != null
					&& memory.getAbsentHours().compareTo(zero) > 0)
				flag = true;
		} else if (searchType.intValue() == 6) {
			if (memory != null && memory.getLeaveHours() != null
					&& memory.getLeaveHours().compareTo(zero) > 0)
				flag = true;
		} else if (searchType.intValue() == 7) {
			if (memory != null && memory.getOvertimeHours() != null
					&& memory.getOvertimeHours().compareTo(zero) > 0)
				flag = true;
		} else if (searchType.intValue() == 8 && memory != null
				&& memory.getComments() != null
				&& memory.getComments().indexOf("\u5237\u5361") > -1)
			flag = true;
		return flag;
	}

	BigDecimal zero;
}
